<template>
    <div class="role">
        <!-- <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/layout/users' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb> -->
        <!-- 抽离了面包屑组件 -->
        <crumbs-nav :level1="'权限管理'" :level2="'权限列表'"></crumbs-nav>
        <template>
            <el-table
              :data="authList"
              border
              style="width: 100%">
              <el-table-column
                type='index'
                label="序号"
                width="50">
              </el-table-column>
              <el-table-column
                prop="authName"
                label="权限名称"
                >
              </el-table-column>
              <el-table-column
                prop="path"
                label="路径">
              </el-table-column>
              <el-table-column
                prop="level"
                label="层级">
              </el-table-column>
            </el-table>
        </template>
    </div>
</template>

<script>

import crumbsNav from '../../common/crumbsNav'
export default {
    name:'Auth',
    components:{
        crumbsNav
    },
    data(){
        return {
            type:'list',
            authList:[]
        }
    },
    created(){
        this.getAuthDate()
    },
    methods:{
        getAuthDate(){
            this.$axios.get(`rights/${this.type}`,{
                params:{
                    type:this.type
                }
            }).then(res => {
                let authList = res.data.data
                authList = authList.map(function(item){
                    if(item.level==0){
                        item.level = '一级'
                    }else if(item.level==1){
                        item.level = '二级'
                    }else if(item.level==2){
                        item.level = '三级'
                    }
                    return item
                })
                this.authList = authList
            })
        }
    }
}
</script>

<style scope>
    
</style>
